#include <cstdio>
#include <cmath>

bool is_prime(int x);

int main(int argc, char const *argv[]){
    int n;
    while(scanf("%d", &n) != EOF){
        if (n == 0)
            break;
        int pair_num = 0;
        for (int i = 2; i <= n/2; i++){
            if (is_prime(i) && is_prime(n-i))
                pair_num++;
        }
        printf("%d\n", pair_num);
    }
    return 0;
}

bool is_prime(int x){
    if (x <= 1)
        return false;
    int bound = (int)sqrt(x) + 1;
    for (int i = 2; i < bound; i++){
        if (x % i == 0)
            return false;
    }
    return true;
}
